package controllers;

import dao.*;
import play.data.FormFactory;
import play.libs.Json;
import play.libs.concurrent.HttpExecutionContext;
import play.mvc.Controller;
import play.mvc.Result;

import javax.inject.Inject;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletionStage;

import com.fasterxml.jackson.databind.JsonNode;  
import com.fasterxml.jackson.databind.node.ObjectNode;


/**
 * The controller keeps all database operations behind the repository, and uses
 * {@link play.libs.concurrent.HttpExecutionContext} to provide access to the
 * {@link play.mvc.Http.Context} methods like {@code request()} and {@code flash()}.
 */
public class ErrorLogController extends Controller {

    private final FormFactory formFactory;
    private final ErrorLog_Repository errorLog_Repository;
    private final HttpExecutionContext ec;

    @Inject
    public ErrorLogController(FormFactory formFactory, ErrorLog_Repository errorLog_Repository, HttpExecutionContext ec) {
        this.formFactory = formFactory;
        this.errorLog_Repository = errorLog_Repository;
        this.ec = ec;
    }
    
    public CompletionStage<Result> getErrorLog() {
	    return errorLog_Repository.getErrorLog().thenApplyAsync(_ErrorInfo -> {
	    	return ok(Json.toJson(_ErrorInfo));
	    }, ec.current());
    }
}
